package com.webtest.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/8/21 9:44
 */
public class HelloServletContextListener implements ServletContextListener, ServletRequestListener, HttpSessionListener {
    private static final Logger LOGGER = LoggerFactory.getLogger(HelloServletContextListener.class);
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        LOGGER.info("ServletContext对象被创建" + servletContextEvent.getServletContext());
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        LOGGER.info("ServletContext对象被销毁"+servletContextEvent.getServletContext());
    }

    @Override
    public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
        LOGGER.info("request被创建");
    }

    @Override
    public void requestInitialized(ServletRequestEvent servletRequestEvent) {
        LOGGER.info("request被销毁");
    }

    @Override
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        LOGGER.info("session被创建");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        LOGGER.info("session被销毁");
    }
}
